/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controller;

import DAO.PropertyDAO;
import Model.PropertyBean;
import javax.inject.Named;
import javax.enterprise.context.SessionScoped;
import java.io.Serializable;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author amkreuz
 */
@Named(value = "searchBean")
@SessionScoped
public class SearchBean implements Serializable {

    private int price,acre;
    private String state;
    
    /**
     * Creates a new instance of SearchBean
     */
    public SearchBean() {
 
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public int getAcre() {
        return acre;
    }

    public void setAcre(int acre) {
        this.acre = acre;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }  

    public ArrayList<PropertyBean> getProperties() {
       
        ArrayList<PropertyBean> test = null;
        try {
            PropertyDAO.init();
            test = PropertyDAO.returnProperties(price,acre);
            PropertyDAO.terminate();
        } catch (SQLException ex) {
            Logger.getLogger(SearchBean.class.getName()).log(Level.SEVERE, null, ex);
        }
        return test;
    }
    
    public ArrayList<PropertyBean> getHighlights() {
                ArrayList<PropertyBean> test = null;
        try {
            PropertyDAO.init();
            test = PropertyDAO.getHighlights();
            PropertyDAO.terminate();
        } catch (SQLException ex) {
            Logger.getLogger(SearchBean.class.getName()).log(Level.SEVERE, null, ex);
        }
        return test;
    }
}
